package demo.practice.linklist;

import demo.practice.ListNode;

public class P203 {

    public ListNode removeElements(ListNode head, int val) {

        //head值为value值，head指针往下移动一位
        while (head!=null && head.val==val)
            head=head.next;

        ListNode current= head;
        while (current.next!=null){
            if(current.next.val==val)
                current.next=current.next.next;
            else
                current=current.next;
        }

        return head;
    }
}
